
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>列表</title>
    {include file="include/top"}
</head>
<body>

<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto">

            <div class="layui-inline">
                <label class="layui-form-label">名称</label>
                <div class="layui-input-inline">
                    <input type="text" name="title" placeholder="请填入..." autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <button class="layui-btn layuiadmin-btn-list" lay-submit lay-filter="LAY-app-contlist-search">
                    <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                </button>
            </div>
        </div>
        <div class="layui-card-header layuiadmin-card-header-auto">
            <button type="button" class="layui-btn" id="test-upload-type1" data-imgid="addfood"><i class="layui-icon"></i>添加</button>
        </div>
        <table class="layui-table" lay-data="{height:0, url:'/finance/yeepaySList', page:true, id:'idTest',toolbar: '#toolbarDemo'}" lay-filter="demo">
            <thead>
            <tr>
<!--                <th lay-data="{field:'id',  sort: true, fixed: true,width:80,checkbox:true}">ID</th>-->
                <th lay-data="{field:'id',  sort: true, fixed: true,width:80}">ID</th>
                <th lay-data="{field:'title'}">名称</th>
                <th lay-data="{field:'shopNo'}">账户编号</th>
                <th lay-data="{field:'contacts'}">联系人</th>
                <th lay-data="{field:'mobile'}">联系电话</th>
<!--                <th lay-data="{field:'amount'}">余额</th>-->
                <th lay-data="{field:'ctype',templet:function(d){
                    if(d.ctype==1)
                        return '商户';
                    else
                        return '个人';
                    }
                }
                ">性质</th>
                <th lay-data="{field:'status',templet:function(d){
                    if(d.status==1)
                        return '正常';
                    else
                        return '暂停';
                    }
                }
                ">状态</th>
                <th lay-data="{fixed: 'right',  align:'center', toolbar: '#barDemo',width:140}"></th>
            </tr>
            </thead>
        </table>
        <script type="text/html" id="toolbarDemo">
        </script>
        <script type="text/html" id="barDemo">
            <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="more">操作<i
                    class="layui-icon layui-icon-down"></i></a>
        </script>
    </div>
</div>
{include file="include/js"}
<script>
    var pathid=0;
    layui.config({
        base: '/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'contlist', 'table', 'dropdown'], function(){
        var table = layui.table;
        var $ = layui.$;
        var form = layui.form;
        var dropdown = layui.dropdown
        var pathid=0,field;
        var id=0;
        $("#test-upload-type1").click(function (){
            id=0;
            add();
        })
        function add(){
            layer.open({
                type: 2
                ,title: '添加修改A2'
                ,content: 'yeepaySAdd?id='+id
                ,btn: ['确定', '取消']
                ,area: ['80%', '80%']
                ,yes: function(index, layero){
                    layer.confirm('是否确定操作?', {icon: 3, title:'提示'}, function(index){
                        //do something
                        var $data={};
                        var othis = layero.find('iframe').contents().find("#layuiadmin-app-form-tags");
                        $data.title = othis.find('input[name="title"]').val()
                        $data.ctype = othis.find('select[name="ctype"]').val()
                        $data.mobile = othis.find('input[name="mobile"]').val()
                        $data.contacts = othis.find('input[name="contacts"]').val()
                        $data.shopNo = othis.find('input[name="shopNo"]').val()
                        $data.content = othis.find('input[name="content"]').val()

                        $.post("yeepaySSave?id="+id,$data,function (re) {
                            layer.msg(re.msg);
                            if(re.code == 0){
                                setTimeout(function () {
                                    location.reload();
                                },2000);
                            }
                        },'json');
                        layer.close(index);
                    });
                }
            });
        }

        //监听搜索
        form.on('submit(LAY-app-contlist-search)', function(data){
            field = data.field;
            //执行重载
            table.reload('idTest', {
                where: field
            });
        });
        $('.layui-btn.layuiadmin-btn-tags').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        function setDisable(obj,menuStr){
            if(menuStr=='启用'){
                layer.confirm("是否确定启用？",function (){
                    $.post("yeepaySSave", {id: id,value:1,field:'status'}, function (res) {
                        layer.closeAll()
                        layer.msg(res.msg,obj)
                    })
                })
            }else{
                layer.confirm("是否确定禁用：",function (re){
                    $.post("yeepaySSave", {id: id,value:-1,field:'status'}, function (res) {
                        layer.closeAll()
                        layer.msg(res.msg,obj)
                    })
                })
            }
        }
        //监听工具条
        table.on('tool(demo)', function(obj){

            var that = this
            var data = obj.data;
            if (obj.event === 'more') {
                //更多下拉菜单
                var thatData = data
                var menuStr="禁用";
                if(thatData.status==-1){
                    menuStr = '启用'
                }
                dropdown.render({
                    elem: that
                    , show: true //外部事件触发即显示
                    , data: [{
                        title: '编辑信息'
                        , id: 'sEdit'
                    },{
                        title: menuStr
                        , id: 'setDisable'
                    },
                    ]
                    , click: function (data, othis) {
                        //根据 id 做出不同操作
                        if (data.id === 'getAmount') {

                        }else if(data.id == 'sEdit'){
                            id = thatData.id
                            add();
                        }else if(data.id == 'setDisable'){
                            id = thatData.id
                            setDisable(obj,menuStr);
                        }
                    }
                    , align: 'right' //右对齐弹出（v2.6.8 新增）
                    , style: 'box-shadow: 1px 1px 10px rgb(0 0 0 / 12%);' //设置额外样式
                });
            }
        });
    });
</script>

</body>
</html>
